/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package statusapp;

/**
 *
 * @author asmith
 */
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;



//The class below inserst data into the database which is then read by the PHP page
//Next step is GUI to change status and repating every 5 minutes
public class Main {
  public static void main(String[] argv) throws Exception {
    try {
        while (true) { 
    String driverName = "org.gjt.mm.mysql.Driver";
    Class.forName(driverName);

    String serverName = "localhost";
    String mydatabase = "home";
    String url = "jdbc:mysql://" + serverName + "/" + mydatabase;
    String username = "root";
    String password = "hoop";
    
    Connection connection = DriverManager.getConnection(url, username, password);
    Statement stmt = connection.createStatement();
    String sql = "UPDATE status SET status='1', date=NOW() WHERE name = 'adam'";
    int updateCount = stmt.executeUpdate(sql);
    Thread.sleep(300 * 1000);
    }
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
  }
}